<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$return=array();
$need=trim($_RQ['need'],';');
$show_need=trim($_RQ['show_need'],';');
$template_dir=ROOT_RESOURCE.($_SESSION['os']=='windows'?'templates':'templates_mobile').'/';
/*if($_SESSION['os']=='mobile'){
	if($need){
		$need=explode(';',$need);
		$common=array();
		$templates=cfc('made_page')->get_template_default_mobile();
		foreach($need as $name){
			if(is_file(ROOT_RESOURCE.'templates_mobile/'.$name.'.html')){
				$template=array('template'=>file_get_contents(ROOT_RESOURCE.'templates_mobile/'.$name.'.html'));
				$template['default']=$templates[$name];
				$common[$name]=$template;
			}
		}
		if($common){
			$return['common']=$common;
		}
	}
}else{
	*/
	if($need){
		$need=explode(';',$need);
		$common=array();
		$templates=cfc('made_page')->get_template_default();
		foreach($need as $name){
			$template_file=$template_dir.$name.'.html';
			if(is_file($template_file)){
				$template=array('template'=>file_get_contents($template_file));
				$template['default']=$templates[$name];
				$common[$name]=$template;
			}elseif($name=='list_shows'){
				$common['list_shows']=array();
				$list_shows=array('copy','ewm','href','href_blank','href_item','icon','image','lat_lng','modal','modal_result','post','radio','select','string','base64_string','switch','time','checkbox','status_string','color','string_open','img_string','credit','price','open','member','array_string','unitstring','time_hour','pay_submit','star');
				foreach($list_shows as $name){
					$show_file=$template_dir.'list_shows/'.$name.'.html';
					if(is_file($show_file)){
						$common['list_shows'][$name]=file_get_contents($show_file);
					}
					
				}
			}elseif($name=='list_edits'){
				$common['list_edits']=array();
				$list_edits=array('switch','string','base64_string','select','radio','post','modal','href','href_blank','checkbox','open','select_item');
				foreach($list_edits as $name){
					$edit_file=$template_dir.'list_edits/'.$name.'.html';
					if(is_file($edit_file)){
						$common['list_edits'][$name]=file_get_contents($edit_file);
					}
					
				}
			}elseif($_RQ['from_plugin']){
				$file=ROOT_PLUGIN.$_RQ['from_plugin'].'/'.$_SESSION['this'].'/diyform/'.$name.'.html';
				if(is_file($file)){
					$template['template']=file_get_contents($file);
					$template['default']=array('name'=>'');
					$common[$name]=$template;
				}
			}else{
				//exi($template_file.'不存在！','error');
			}
		}
		if($common){
			$return['common']=$common;
		}
	}
	
	if($show_need){
		$show_need=explode(';',$show_need);
		$show=array();
		$templates=cfc('made_page')->get_template_show_default();
		foreach($show_need as $name){
			if(is_file($template_dir.'edit_show/'.$name.'.html')){
				$template=array('template'=>file_get_contents($template_dir.'edit_show/'.$name.'.html'));
				$template['default']=$templates[$name];
				$show[$name]=$template;
			}
		}
		if($show){
			$return['show']=$show;
		}
	}
/*
}*/
exi($return);

